﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Show.aspx.cs" Inherits="MyBBS.Views.Post.Show" %>
<%@ Import Namespace="MyBBS.Data.Extensions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
<div class="post">
    <% var post = ViewData.Model.PostInfo;%>
    <% if (post == null) %>
    <% { %>
         <span class="pageMessage">The post does not exists.</span>
    <% } %>
    <% else%>
    <% { %>
    <%  this.Title = post.Title; %>
    <table>
        <tr>
           <td class="kick">
                <div class="postCount">
                    <span id="Kick<%= post.ID %>"><%= post.KickCount %></span>            
                </div>
                <div class="action">
                    <a onclick="javascript:Kick(<%= post.ID %>)" onmouseover="javascript:style.cursor='hand'">kick</a>
                </div>
            </td>
            <td class="content">
                <div class="title">
                    <a href="<%= post.URL %>" target="_blank"><%= post.Title %></a>
                </div>                               
                <div class="description">
                     <%= post.Description %>&nbsp;
                </div>
                <div class="summary">
                    <span class="commentInfo"><%= post.Comments.Count %>&nbsp;comments&nbsp;<span class="share">share</span><span class="bury">bury</span>posted by <span><%= post.Author %></span><span class="time"><%= post.PostedTime.Ago() %></span> &nbsp;
                </div>
            </td>
        </tr>
    </table>
</div>
    <div class="divider"></div>
        <div>
            <div class="pageTitle">
                <a name="comments">Comments</a>
            </div>
            <div>
                <div id="comments">
                    <% if (post.Comments.Count == 0) %>
                    <% { %>
                        <span class="pageMessage">Be the first one to comment.</span>
                    <% } %>
                    <% else %>
                    <% { %>
                    <%  bool isOdd = true; %>
                    <%  foreach(MyBBS.Data.Models.Comment comment in post.Comments) %>
                    <%  { %>
                    <%   string className = (isOdd) ? "odd" : "even"; %>
                    <%   isOdd = !isOdd;%>
                        <div class="comment <%= className %>">
                            <div>
                                <%= Server.HtmlDecode(comment.Content) %>
                            </div>
                            <div class="postedBy">
                                posted by
                                <span class="user">
                                   <%= comment.Author %>
                                </span>
                                <span class="time"><%= comment.SubmitTime.Ago() %></span>
                            </div>
                        </div>
                    <%  } %>
                    <% } %>
                </div>
            </div>
            <div class="divider"></div>
            <div style="width:520px">
                <div class="form">
                    <h2>Post Your Comment</h2>                    
                    <p>
                        <textarea id="txtComment" cols="20" rows="8" class="largeTextarea"></textarea>
                    </p>
                    <p id="name">
                        Your Name:<input id="txtAuthor" type="text" name="txtAuthor" />
                    </p>
                    <div id="commentMessage" style="display:none;padding-top:2px;padding-bottom:2px; color:Red"></div>
                    <p>                      
                        <input id="btnSubmitComment" type="button" class="button" value="Submit"/>
                    </p>
                </div>
            </div>
        </div>
        <div class="divider"></div> 
    <%} %>

<script type="text/javascript">
    $(document).ready(
        function()
        {
           $("#btnSubmitComment").click(function()
            {
                var post = new Post();
                post.comment("<%= post.ID.ToString() %>");         
            })            
           
        }
    );
</script>
</asp:Content>

